package someclass;

public class userLogin {
        public int[] userId;
        public String[] userName;
        public String[] userPassword;
        public boolean[] iflogin;
        public boolean loginInputRight;
        public userLogin(){
            userId = new int[]{0,1,2,3,4};
            userName = new String[]{"001", "002","003","004","005"};
            userPassword = new String[]{"001", "002","003","004","005"};
            iflogin = new boolean[]{false,false,false,false,false};

        }
    public String showWelcome(){
        String welcomeMess = "Welcome to Biblioteca System!";
        System.out.println(welcomeMess);
        return welcomeMess;
    }
    public String showPromptMessage() {
        String prompt;
        prompt = "Please input right username and password to login:";
        return prompt;
    }

    public boolean checkUsername(String username,String password) {
        boolean checkResult=false;
        for(int i=0;i<userName.length;i++){
            if(username.equals(userName[i])){
                if(userPassword[i].equals(password)){
                    checkResult = true;
                    loginInputRight = true;
                    iflogin[i] = true;
                    break;
                }
            }
        }
        return checkResult;
    }

    public String showWrongMessage() {
        String wrongMessage="";
        if(!loginInputRight)
            wrongMessage = "Input wrong,please input again!";
        return wrongMessage;
    }
}
